import { AppSetting } from "../AppSetting";
import { Container } from "../Container";
import { BaseGui } from "../Services/BaseGui";

export class AboutGui extends BaseGui {
    title: string = `关于软件(${AppSetting.Version})[${AboutGui.name}]`;
    c = Container.defineProperty(Container);
    protected UpdateGui(): void {
        let guis = this.c.GetInstances().filter(_ => _.Value != undefined && _.Value instanceof BaseGui && _.Value.Level>0).map(_ => _.Value as BaseGui);
        guis.forEach(_=>_.Close());
        let fun = {
            data: -1,
            _dataOptions: () => {
                let options = {} as any;
                guis.forEach((v, i) => {
                    const name = `[${i + 1}]${v.title}`;
                    options[name] = i;
                });
                return options;
            },
            _dataChanged: () => {
                fun.visible = guis[fun.data].Visible;
                updateGUI();
            },
            visible: true,
            _visibleChanged: () => {
                fun.visible ? guis[fun.data].Show() : guis[fun.data].Close();
            }
        }
        let gui = this.gui;
        let updateGUI = () => {
            Array.from(gui.__controllers).forEach(_ => {
                gui.remove(_);
            });
            this.guiService.buildGUIByObject(this.gui, fun);
        }
        updateGUI();
    }
}
export class TestClass extends BaseGui {

}